package com.hengdu.cms.common;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class TopicCustomer {

	@RabbitListener(bindings = { 
			@QueueBinding(
				value = @Queue, // 创建临时队列
				exchange = @Exchange(type = "topic",name="topics"), // 自定义交换机名称和类型
				key = { "user.save", "user.*" } // 路由信息
			) })
	public void recevice1(String message) {

		System.out.println("消费者1:" + message);
	}

	@RabbitListener(bindings = { 
			@QueueBinding(
				value = @Queue, // 创建临时队列
				exchange = @Exchange(type = "topic",name="topics"), // 自定义交换机名称和类型
				key = { "order.#", "user.#" } // 路由信息
		) })
	public void recevice2(String message) {

		System.out.println("消费者2:" + message);
	}

}
